<template>
  <div>
    <el-table
      :data="cartItemList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        label="书名">
        <template slot-scope="scope">
          {{scope.row.book.bookName}}
        </template>
      </el-table-column>
      <el-table-column
        label="原价">
        <template slot-scope="scope">
          {{scope.row.book.bookPrice}}
        </template>
      </el-table-column>
      <el-table-column
        label="现价">
        <template slot-scope="scope">
          {{scope.row.book.dangprice}}
        </template>
      </el-table-column>
      <el-table-column
        prop="count"
        label="数量">
      </el-table-column>

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <router-link to=""><el-button>删除</el-button></router-link>
        </template>
      </el-table-column>
    </el-table>
    <el-row :gutter="10" v-if="cartItemList.length>0">
     <el-col :span="18">总金额：{{cart.totalMoney}}元</el-col>
     <el-col :span="6"><el-button>生成订单</el-button></el-col>
    </el-row>
  </div>
</template>

<script>
    export default {
        name: "cart",
      data(){
          return {
            cart:{},
            cartItemList:[]
          }
      },
      created(){
        //发出ajax请求请求后端代码
        this.axios.get("/cart/myCart").then((resp)=>{
          this.cart=resp.data;
          for(let i in this.cart.buyMap){
            this.cartItemList.push(this.cart.buyMap[i]);
          }
        });
      }
    }
</script>

<style scoped>

</style>
